<template>
	<view class="detail">
		<view v-if="type == 1">
			<tui-list-view :title="title">
				<tui-list-cell>
					<tui-row>
						<tui-col :span="24">
							<input class="detailInput" type="text" placeholder="请输入残疾人名称" v-model="disabledName" />
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">员工姓名</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.name||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">身份证号</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.idCard||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">企业名称</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.enterpriseName||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">考勤时间</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.attendanceTime||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">实际打卡时间</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.actualAttendanceTime||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">考勤时间段</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.attendanceTimeType == 1?"早上":"下午"}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">考勤状态</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								<text v-if="info.attendanceStatus == 1">正常</text>
								<text v-else-if="info.attendanceStatus == 2">迟到</text>
								<text v-else-if="info.attendanceStatus == 3">早退</text>
								<text v-else-if="info.attendanceStatus == 4">事假</text>
								<text v-else-if="info.attendanceStatus == 5">调休假</text>
								<text v-else-if="info.attendanceStatus == 6">旷工</text>
								<text v-else-if="info.attendanceStatus == 7">正常上班</text>
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">审核状态</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.examineStatus == 1?"通过":"不通过"}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="12">
							<view class="detailBtn" style="background: #ff4d4f;margin-right: 15rpx;" @click="attendanceSubmit(2)">不通过
							</view>
						</tui-col>
						<tui-col :span="12">
							<view class="detailBtn" style="margin-left: 15rpx;" @click="attendanceSubmit(1)">通过</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
			</tui-list-view>
		</view>
		<view v-else>
			<tui-list-view :title="title">
				<tui-list-cell>
					<tui-row>
						<tui-col :span="24">
							<input class="detailInput" type="text" placeholder="请输入残疾人名称" v-model="disabledName" />
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">员工姓名</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.name||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">身份证号</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.idCard||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">性别</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.sex == 1 ? "男" : "女"}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">户籍</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.registeredResidence||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">户口性质</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.resident||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">民族</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.nation||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">教育程度</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.educationLevel||'--'}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="8">审核状态</tui-col>
						<tui-col :span="16">
							<view style="width: 100%;text-align: right;">
								{{info.examineStatus == 1?"通过":"不通过"}}
							</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
				<tui-list-cell>
					<tui-row>
						<tui-col :span="12">
							<view class="detailBtn" style="background: #ff4d4f;margin-right: 15rpx;" @click="infoSubmit(2)">不通过
							</view>
						</tui-col>
						<tui-col :span="12">
							<view class="detailBtn" style="margin-left: 15rpx;" @click="infoSubmit(1)">通过</view>
						</tui-col>
					</tui-row>
				</tui-list-cell>
			</tui-list-view>
		</view>
	</view>
</template>

<script>
	const util = require("@/utils/util.js")
	const app = getApp()
	export default {
		data() {
			return {
				info: {},
				id: "",
				type: "",
				title: "",

				disabledName: "",
			}
		},
		onLoad(option) {
			if (option.id) {
				this.id = option.id;
				this.type = option.type;
				this.title = option.type == 1 ? '考勤记录详情' : '数据处理记录详情'
				this.getDetail();
			}
		},
		filters: {
			// 日期文字处理
			filterDate(value, num) {
				if (!value) return '--'
				if (value.length > num) {
					return value.slice(0, num)
				}
				return value
			},
		},
		methods: {
			// 查看会员信息
			getDetail() {
				if (this.type == 1) {
					util.request('disabled/detailDisabledAttendance', {
						id: this.id,
					}, "POST").then(res => {
						if (res.code == 1) {
							this.info = res.data;
						}
					});
				} else {
					util.request('disabled/detailDisabledCheck', {
						id: this.id,
					}, "POST").then(res => {
						if (res.code == 1) {
							this.info = res.data;
						}
					});
				}
			},
			// 考勤审核
			attendanceSubmit(type) {
				if (!this.disabledName) {
					return util.toast("请输入残疾人姓名");
				}
				util.request('disabled/updateAttendanceExamine', {
					id: this.id,
					examineStatus: type,
					disabledName: this.disabledName
				}, "POST").then(res => {
					if (res.code == 1) {
						util.toast("操作成功");
						setTimeout(()=> {
							uni.navigateBack(-1);
						}, 1500)
					}
				});
			},
			// 数据处理审核
			infoSubmit(type) {
				if (!this.disabledName) {
					return util.toast("请输入残疾人姓名");
				}
				util.request('disabled/updateCheckExamine', {
					id: this.id,
					examineStatus: type,
					disabledName: this.disabledName
				}, "POST").then(res => {
					if (res.code == 1) {
						util.toast("操作成功");
						setTimeout(()=> {
							uni.navigateBack(-1);
						}, 1500)
					}
				});
			}
		}
	}
</script>
<style>
	page {
		background-color: #f1f1f1;
	}
</style>
<style lang="scss" scoped>
	.detail {
		.detailInput {
			width: 100%;
			height: 70rpx;
			border: 1px solid #eee;
			padding: 0 20rpx;
			border-radius: 12rpx;
			box-sizing: border-box;
		}

		.detailBtn {
			width: 100%;
			line-height: 88rpx;
			text-align: center;
			background: #EED1A7;
			color: #fff;
			font-size: 28rpx;
			border-radius: 12rpx;
		}
	}
</style>